const api = require('./api')
// 选择章节
  const bindPickerChange=(that,e)=>{
    let value = e.detail.value
    let ti_info = that.data.ti_info
    ti_info.chap_id = that.data.chap_list[value].chap_id
    ti_info.chap_name = that.data.chap_list[value].chap_name
    that.setData({
      ti_info:ti_info
    })
  }

  // 选择章节
  const ana_pic=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.ana_pic_list[0] = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }

  const ana_video=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.ana_video_list[0] = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }

  const question=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.question = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }
  const a=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.a = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }
  const b=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.b = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }
  const c=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.c = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }
  const answer=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.answer = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }
  const analysis=(that,e)=>{
    let ti_info = that.data.ti_info
    ti_info.analysis = e.detail.value
    that.setData({
      ti_info:ti_info
    })
  }

const submit=(that,e)=>{

    if(that.data.ti_info.chap_id){
      wx.showModal({
        cancelColor: '#1aad19',
        cancelText: '取消',
        confirmColor: '#999',
        confirmText: '提交',
        content: '确定提交吗？',
        showCancel: true,
        title: '提示',
        success: res=> {
          if(res.confirm){
            api.edit_ti(that)
          }
        },
      })
    }else{
      wx.showModal({
        content: '请选择该题所属章节',
        showCancel: false,
        title: '提示',
      })
    }
  }


  module.exports={
    bindPickerChange:bindPickerChange,
    ana_pic:ana_pic,
    ana_video:ana_video,
    question:question,
    a:a,
    b:b,
    c:c,
    answer:answer,
    analysis:analysis,
    submit:submit,
  }